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(HL)
	EX	DE,HL
LFC71	CALL	PO,OUT_BIT0
LFC74	CALL	PE,OUT_BIT1
	INC	DE
	SBC	HL,DE
	CALL	OUT_BIT1
	EX	DE,HL
	JP	NZ,LFC28
	CALL	OUT_BIT1
	IN	A,(#EF)
	EI
	RET
;
LFC88	CALL	LFCD6
	JR	LFC8F
OUT_BIT1
	LD	B,1
LFC8E	EQU	$-1
LFC8F	IN	A,(#EF)
	CALL	LFCB2
	OUT	(#EF),A
	CALL	LFCB9
	DJNZ	LFC88
	RET
;
LFC9C	CALL	LFCD4
	JR	LFCA4
OUT_BIT0
	PUSH	AF
	LD	B,#02
LFCA3	EQU	$-1
LFCA4	IN	A,(#EF)
	CALL	LFCC2
	OUT	(#EF),A
	CALL	LFCCA
	DJNZ	LFC9C
	POP	AF
	RET
;
LFCB2	PUSH	BC
	LD	B,#6B
LFCB5	DJNZ	LFCB5
	POP	BC
	RET
;
LFCB9	PUSH	BC
	LD	B,#69
LFCBC	DJNZ	LFCBC
	LD	A,#00
	POP	BC
	RET
;
LFCC2	PUSH	BC
	LD	B,#33
LFCC5	DJNZ	LFCC5
	POP	BC
	XOR	A
	RET
;
LFCCA	PUSH	BC
	LD	B,#2C
LFCCD	DJNZ	LFCCD
	POP	BC
	LD	A,#00
	NOP
	RET
;
LFCD4	PUSH	BC
	POP	BC
LFCD6	LD	A,#00
	LD	A,#00
	RET
;
T_TRANS	DEFB	"TRANSMIT "
	DEFB	1
;
T_RECEI	DEFB	"RECEIVE "
	DEFB	1
;
T_ERROR
	DEFB	" ERROR	"
	DEFB	2
T_COMA
	DEFB	0
;
T_MAIN	DEFB	"  Copyright (Research)soft'94	 "
	DEFB	" ZX-MODEM by Morohovsky Victor	 "
	DEFB	"     CCITT - V24 standard.	 "
	DEFB	"Stop bit = 1; Start bit = 0	 "
	DEFB	"Parity:   ODD:EVEN (P to select)"
	DEFB	"Baud rate:600:1200 (B to select)"
	DEFB	"  PRESS: Q for	QUIT		 "
	DEFB	"  T for TRANSMIT, R for RECEIVE "
	DEFB	"   (Transmit X,Y ; Receive X)	 "
	DEFB	"________________________________"
	DEFB	0
;
EOF

